<template>
  <div class="card">
    <h3>单一文件上传「BASE64」(只适合图片)</h3>
    <section class="upload_box" id="upload2">
      <input
        ref="inputRef"
        type="file"
        class="upload_inp"
        accept=".png,.jpg,.jpeg"
        @change="changeFile"
      />
      <div class="upload_button_box">
        <button
          :class="[loading ? 'loading' : '']"
          class="upload_button select"
          @click="selectFile"
        >
          上传图片
        </button>
      </div>
      <div class="upload_tip">
        只能上传 PNG/JPG/JPEG 格式图片且大小不能超过2MB
      </div>
    </section>
  </div>
</template>

<script setup>
import { useUploadBase } from "@/hook";
// 封装上传钩子
let { inputRef, loading, selectFile, changeFile } = useUploadBase();
</script>
